﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Shop.Data;
using Shop.Resources;

namespace Shop.AllForms
{
    public partial class QueryExpDate : Form
    {
        public QueryExpDate()
        {
            InitializeComponent();
        }

        private void buttonSearch_Click(object sender, EventArgs e)
        {
            DateTime expDate = dateTimePickerExpDate.Value;
            dGVProductsByExpDate.DataSource = ShopData.GetProductsByExpDate(expDate);
        }

        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonExport_Click(object sender, EventArgs e)
        {
            if (dGVProductsByExpDate.RowCount == 0)
            {
                MessageBox.Show("Няма открити продукти, които да експортвате");
                return;
            }
            else
            {
                dGVProductsByExpDate.ExportToExcel();
            } 
        }
    }
}
